#pragma once


#include "HashTable.h"


namespace chen
{
	template<class K, class V>
	class map
	{
		struct MapOfKey
		{
			const K& operator()(const pair<K, V>& kv)
			{
				return kv.first;
			}
		};

	public:
		typedef typename hash_bucket::HashTable<K, pair<const K, V>, MapOfKey>::iterator iterator;
		typedef typename hash_bucket::HashTable<K, pair<const K, V>, MapOfKey>::const_iterator const_iterator;

		iterator begin()
		{
			return _t.begin();
		}

		iterator end()
		{
			return _t.end();
		}

		

		pair<iterator, bool> insert(const pair<K, V>& kv)
		{
			return _t.Insert(kv);
		}

		V& operator[](const K& key)
		{
			pair<iterator, bool> it = _t.Insert({key, V()});
			return it.first->second;
		}

	private:
		hash_bucket::HashTable<K, pair<const K, V>, MapOfKey> _t;
	};
}